using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;

namespace SignalrServer.Hubs
{
    public class Chat : Hub
    {
        public override async Task OnConnectedAsync()
        {
            // await Groups.AddAsync(Context.ConnectionId, "test");
            // await Clients.Group("test").InvokeAsync("method");
            await Clients.All.InvokeAsync("Connected", Context.ConnectionId);
            await base.OnConnectedAsync();
        }
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            await Clients.All.InvokeAsync("Disconnect", Context.ConnectionId);
            await base.OnDisconnectedAsync(exception);
        }
        public Task Send(string message)
        {
            return Clients.All.InvokeAsync("Send", Context.ConnectionId + message);
        }
        public Task Test(string msg)
        {
            return Clients.All.InvokeAsync("Test", Context.ConnectionId + msg);
        }
    }
}